package chapter06

/**
 * 访问权限
 */
object Test04_Access {
  def main(args: Array[String]): Unit = {
    //创建对象
    val person = new Person()
//    person.idCard  error 私有无法访问
    println(person.age)
    println(person.sex)
    person.printInfo
//    println(person.name) //设置的访问权限 只能当前包或者子类


    val worker = new Worker()
  worker.printInfo
  }
}


/**
 * 创建子类继承父类
 */
class Worker extends Person {
  override def printInfo: Unit = {
    println("Worker: ")
//    println(idCard) error

    name ="张三"
    age=20
    sex="男"

    println(s"Worker:  $name $sex $age")
  }
}